FROM {{.registry}}/{{.upstream}}

# Must Debian
{{if .debian_version}}
{{else}}
BAD
{{end}}

{{if .install_devel}}
{{if .debian_version}}
RUN apt-get update && \
    apt-get install -y build-essential git && \
    rm -rf /var/lib/apt/lists/*
{{end}}
{{end}}

{{if .node_version}}
RUN curl -sSL -o node.tar.gz "{{.node_download_url}}" && \
    mkdir -p /opt/node && \
    tar -C /opt/node --strip-components 1 -xf node.tar.gz && \
    rm -f node.tar.gz

ENV PATH "/opt/node/bin:${PATH}"
ENV NODE_VERSION {{.node_version}}

RUN npm config set unsafe-perm true && \
    npm config set registry https://registry.npmmirror.com
{{end}}

{{if .install_cnpm}}
RUN npm install -g cnpm && \
    npm cache clean -f && \
    cnpm config set unsafe-perm true
{{end}}

{{if .install_yarn}}
RUN npm install -g yarn && \
    npm cache clean -f && \
    yarn config set cache-folder $HOME/.npm/yarn && \
    yarn config set registry https://registry.npmmirror.com
{{end}}

{{if .install_python}}
RUN apt-get update && \
    apt-get install -y python3 python3-dev python3-venv python3-pip && \
    rm -rf /var/lib/apt/lists/*
ADD pip.conf /root/.pip/pip.conf
{{end}}
